//package com.ksd.web.controller.system;
//
//import com.ksd.common.core.controller.BaseController;
//import com.ksd.common.core.domain.AjaxResult;
//import com.ksd.framework.web.domain.Server;
//import com.ksd.framework.web.domain.server.*;
//import com.ksd.quartz.util.TaskConstans;
//import com.ksd.system.domain.*;
//import com.ksd.system.service.*;
//import com.ksd.web.controller.domain.ContentData;
//import com.ksd.web.controller.domain.FirstDataResult;
//import com.ksd.web.controller.domain.OnlineDevice;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.text.DecimalFormat;
//import java.util.ArrayList;
//import java.util.List;
//
//@RestController
//public class FirstController extends BaseController {
//
//    private static final Logger logger = LoggerFactory.getLogger(FileTreeController.class);
//    @Autowired
//    private ISysContentDataService sysContentDataService;
//    @Autowired
//    private ISysTvDataService sysTvDataService;
//    @Autowired
//    private ISysTvTypeService sysTvTypeService;
//    @Autowired
//    private ISysChannelTwiceService sysChannelTwiceService;
//    @Autowired
//    private ISysChannelOneService sysChannelOneService;
//    @Autowired
//    private ISysChannelService sysChannelService;
//    @Autowired
//    private ISysChannelTemplateService sysChannelTemplateService;
//    @Autowired
//    private ISysFreqService sysFreqService;
//
//    @GetMapping("/api/contentFileData")
//    public AjaxResult getContentFileData() {
//
//        FirstDataResult firstDataResult = new FirstDataResult();
//        SysTvType sysTvType = new SysTvType();
//        List<SysTvType> sysTvTypes = sysTvTypeService.selectSysTvTypeList(sysTvType);
//
//        List<ContentData> contentDataList = new ArrayList<>();
//
//        for (SysTvType tvType : sysTvTypes) {
//            SysTvData sysTvData = new SysTvData();
//            sysTvData.setTypeId(tvType.getId());
//            List<SysTvData> sysTvDataList = sysTvDataService.selectSysTvDataList(sysTvData);
//
//            for (SysTvData tvData : sysTvDataList) {
//                Long id = tvData.getId();
//                SysContentData sysContentData = new SysContentData();
//                sysContentData.setFileType(Integer.valueOf(SysTvType.movieDefaultId.toString()));
//                sysContentData.setTypeData(Integer.valueOf(id.toString()));
//
//                List<SysContentData> sysContentData1 = sysContentDataService.selectSysContentDataList(sysContentData);
//                if (sysContentData1.size() != 0){
//                    ContentData contentData = new ContentData();
//                    contentData.setCat_id(id.toString());
//                    contentData.setCat_name(tvData.getName());
//                    contentData.setNum(String.valueOf(sysContentData1.size()));
//                    contentDataList.add(contentData);
//                }
//            }
//        }
//
//
//        firstDataResult.setAccess(contentDataList);
//
//        Server server = new Server();
//        try {
//            server.copyTo();
//        } catch (Exception e) {
//            throw new RuntimeException(e);
//        }
//
//        Cpu cpu = server.getCpu();
//        Mem mem = server.getMem();
//        Jvm jvm = server.getJvm();
//
//        DecimalFormat df = new DecimalFormat("#.00");
//        String formattedNumber = df.format(cpu.getSys());
//        String formattedNumber1 = df.format(mem.getUsed());
//        String formattedNumber2 = df.format(server.getSysFiles().get(0).getUsage());
//
//        firstDataResult.setCpu(formattedNumber+"%");
//        firstDataResult.setMemory(formattedNumber1+"%");
//        firstDataResult.setDisk(formattedNumber2+"%");
//
//
////        List<SysChannelOne> sysChannelOnesSelected = sysChannelOneService.selectSysChannelListByOrStatus(TaskConstans.status_selected,TaskConstans.status_selected);
////        List<SysChannelTwice> sysChannelTwicesSelected = sysChannelTwiceService.selectSysChannelListByOrStatus(TaskConstans.status_selected, TaskConstans.status_selected);
//
//        SysChannelTemplate selectChannel = new SysChannelTemplate();
//        selectChannel.setStatus(TaskConstans.status_selected);
//        List<SysChannelTemplate> sysChannelTemplates = sysChannelTemplateService.selectSysChannelTemplateList(selectChannel);
//
//
//        List<SysChannelOne> sysChannelOnesInit = sysChannelOneService.selectSysChannelListByAndStatus(TaskConstans.status_init);
//        List<SysChannelTwice> sysChannelTwicesInit = sysChannelTwiceService.selectSysChannelListByAndStatus(TaskConstans.status_init);
//
//        System.out.println(sysChannelOnesInit.size());
//        System.out.println(sysChannelTwicesInit.size());
//
//        System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
//        List<SysChannel> sysChannelOneInit = sysChannelService.selectSysChannelListByAndStatus(TaskConstans.status_init, SysChannel.table_one);
//        List<SysChannel> sysChannelTwiceInit = sysChannelService.selectSysChannelListByAndStatus(TaskConstans.status_init, SysChannel.table_twice);
//        System.out.println(sysChannelOneInit.size());
//        System.out.println(sysChannelTwiceInit.size());
//        SysChannel sysChannel = new SysChannel();
//        sysChannel.setBoardId(1L);
//        List<SysChannel> sysChannels = sysChannelService.selectSysChannelList(sysChannel, SysChannel.table_one);
//        System.out.println("sysChannel one: "+sysChannels.size());
//        SysChannel sysChannel1 = sysChannelService.selectSysChannelById(1L, SysChannel.table_twice);
//        System.out.println("=========id==="+sysChannel1.getName());
//        SysChannel sysChannel2 = sysChannelService.selectSysChannelByName("CCTV-1 标清", SysChannel.table_twice);
//        System.out.println("========name===="+sysChannel2.getName());
//
//        SysFreq sysFreq = sysFreqService.selectSysFreqById(1L, SysFreq.table_one);
//        System.out.println("freq:"+sysFreq.getFreq());
//        List<SysFreq> sysFreqs = sysFreqService.selectSysFreqList(sysFreq, SysFreq.table_one);
//        System.out.println("=============freqs:"+sysFreqs.size());
//        List<SysFreq> sysFreqs1 = sysFreqService.selectSysFreqListByFreq(sysFreq, SysFreq.table_one);
//        System.out.println("sysFreqs1:"+sysFreqs1.size()+"============"+sysFreq.getFreq()+"======");
//        SysFreq sysFreqNew = new SysFreq();
//        sysFreqNew.setFreq(sysFreq.getFreq());
//        List<SysFreq> sysFreqs2 = sysFreqService.selectSysFreqListByFreq(sysFreqNew, SysFreq.table_twice);
//        System.out.println("sysFreqs2:"+sysFreqs2.size());
//
//        OnlineDevice onlineDevice = new OnlineDevice();
//        onlineDevice.setOnline(sysChannelTemplates.size());
//        onlineDevice.setOutline(sysChannelOnesInit.size()+sysChannelTwicesInit.size());
//        firstDataResult.setOnlineDevice(onlineDevice);
//        String runTime = jvm.getRunTime();
//        firstDataResult.setUpTime(runTime);
//
//        firstDataResult.setPhpStatus(false);
//        firstDataResult.setPushCardStatus(true);
//        firstDataResult.setLiveCardStatus(true);
//        firstDataResult.setRouterStatus(true);
//        firstDataResult.setX86(true);
//
//        return success(firstDataResult);
//    }
//
//    public static void main(String[] args) {
//        double number = 123.45678;
//        // 创建 DecimalFormat 对象，指定保留两位小数的模式
//        DecimalFormat df = new DecimalFormat("#.00");
//        String formattedNumber = df.format(number);
//        System.out.println("使用 DecimalFormat 保留两位小数: " + formattedNumber);
//    }
//}
